<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="ID" align="center" prop="did" />
      <el-table-column label="公司名称" align="center" prop="dname" />
      <el-table-column label="联系人" align="center" prop="contacts" />
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="公司地址" align="center" prop="companyaddress" />
      <el-table-column label="营业图片" align="center" prop="yingye" >
        <template #default="scope">
          <el-image :src="scope.row.yingye" style="width: 100px; height: 100px"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="zhengmian" label="身份证正面" align="center">
        <template #default="scope">
          <el-image :src="scope.row.zhengmian" style="width: 100px; height: 100px"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="身份证反面" align="center" prop="fanmian" >
        <template #default="scope">
          <el-image :src="scope.row.fanmian" style="width: 100px; height: 100px"></el-image>
        </template>
      </el-table-column>
      <el-table-column
          prop="status"
          label="状态">
        <template slot-scope="scope">
          <div v-if="scope.row.status == 1">
            <van-icon name="success" color="red" />
            <span>通过</span>
          </div>
          <div v-if="scope.row.status == 2">
            <van-icon name="success" color="green" />
            <span>不通过</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="dianji3(scope.row)"
          >通过
          </el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="dianji4(scope.row)"
          >不通过
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>


<script>
import axios from "axios";

export default {
  data() {
    return {
      tableData: [],
      dialogVisible:false,
      form:{
        dname:'',
        contacts:'',
        phone:'',
        companyaddress:'',
        yingye:'',
        zhengmian:'',
        fanmian:'',
        did:'',
      }
    }
  }, methods: {
    dianji3(row) {
      console.log('----------'+row.did);
      axios.get("http://localhost:9000/plant-Agent/agent/updatestatus3?did="+row.did).then(res => {
        if (res.data ==1) {
          this.$message.success('审核通过')
          this.getList()
        } else {
          this.$message.error(res.msg)
        }
      });
    },
    dianji4(row) {
      console.log('----------'+row.did);
      axios.get("http://localhost:9000/plant-Agent/agent/updatestatus4?did="+row.did).then(res => {
        if (res.data ==1) {
          this.$message.success('审核不通过')
          this.getList()
        } else {
          this.$message.error(res.msg)
        }
      });
    },
    getList() {
      axios.get("http://localhost:9000/plant-Agent/agent/findAgent").then(res => {
        this.tableData = res.data;
      })
    }
  },created() {
    this.getList();
  }
}
</script>